package jmm;

import lombok.extern.java.Log;
import org.openjdk.jol.info.ClassLayout;

/**
 * @ClassName jmm04
 * @date 2021/4/2 18:27
 * @Version 1.0
 * @Description //模拟偏向锁升级为轻量级锁
 * @USER root
 */
@Log
public class jmm04 {

    public static void main(String[] args) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Object o = new Object();
        log.info(ClassLayout.parseInstance(o).toPrintable());
        new Thread(()->{
            synchronized (o){
                log.info(ClassLayout.parseInstance(o).toPrintable());
            }
        }).start();

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(()->{
            synchronized (o){
                log.info(ClassLayout.parseInstance(o).toPrintable());
            }
        }).start();

    }
}
